﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyNhaHang.GUI
{
    public partial class Main : Form
    {
        GUI.Order order;
        GUI.Production pro;
        GUI.ComponentMng com;
        String tagetFrm = null;

        public Main()
        {
            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {

            showAnyThing("order");

            //GUI.TKDT mtkdt = new TKDT();
            //tkdt.TopLevel = false;
            //tkdt.AutoScroll = true;
            //this.panelMidTotal.Controls.Add(tkdt);
            //tkdt.Show();

            //GUI.TKSP tksp = new TKSP();
            //tksp.TopLevel = false;
            //tksp.AutoScroll = true;
            //this.panelMidTotal.Controls.Add(tksp);
            //tksp.Show();

        }

        private void btnPhucVu_Click(object sender, EventArgs e)
        {
            showAnyThing("order");
        }

        private void btnThucDon_Click(object sender, EventArgs e)
        {
            showAnyThing("production");
        }

        private void btnThanhPhan_Click(object sender, EventArgs e)
        {
            showAnyThing("components");
        }

        private void showAnyThing(String s)
        {
         
            if (s == "order" && tagetFrm != "order")
            {

                tagetFrm = "order";
                this.panelMidTotal.Controls.Clear();
                order = new GUI.Order();
                order.TopLevel = false;
                order.AutoScroll = true;
                this.panelMidTotal.Controls.Add(order);
                order.Show();
            }
            else if (s == "production" && tagetFrm != "production")
            {
                tagetFrm = "production";
                this.panelMidTotal.Controls.Clear();
                pro = new GUI.Production();
                pro.TopLevel = false;
                pro.AutoScroll = true;
                this.panelMidTotal.Controls.Add(pro);
                pro.Show();
            }
            else if (s == "components" && tagetFrm != "components")
            {
                tagetFrm = "components";
                this.panelMidTotal.Controls.Clear();
                com = new ComponentMng();
                com.TopLevel = false;
                com.AutoScroll = true;
                this.panelMidTotal.Controls.Add(com);
                com.Show();
            }
            else if (s == "tkdt" && tagetFrm != "tkdt")
            {
                tagetFrm = "tkdt";
                this.panelMidTotal.Controls.Clear();
                GUI.TKDT tk = new TKDT();
                tk.TopLevel = false;
                tk.AutoScroll = true;
                this.panelMidTotal.Controls.Add(tk);
                tk.Show();
            }
            else if (s == "tksp" && tagetFrm != "tksp")
            {
                tagetFrm = "tksp";
                this.panelMidTotal.Controls.Clear();
                GUI.TKSP sp = new TKSP();
                sp.TopLevel = false;
                sp.AutoScroll = true;
                this.panelMidTotal.Controls.Add(sp);
                sp.Show();
            }


        }

        private void btnThongKe_Click(object sender, EventArgs e)
        {
            showAnyThing("tkdt");
        }

        public void showNotificationMain(String str)
        {
            Thread t1 = new Thread(() =>
            {
                lblNotification.Invoke(new MethodInvoker(delegate()
                {
                    lblNotification.Text = str;
                }));

                Thread.Sleep(2000);

                lblNotification.Invoke(new MethodInvoker(delegate()
                {
                    lblNotification.Text = "Hello";
                }));
            });
            t1.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            showNotificationMain("asdasd");
        }

    }
}
